﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TPagerQuestion_Edit.aspx.cs" Inherits="ExamSystem.ht.TPagerQuestion_Edit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>试卷试题编辑</title>
	<meta charset="utf-8"/>
	<meta name="renderer" content="webkit|ie-comp|ie-stand"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="stylesheet" type="text/css" href="../h-ui/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="../h-ui/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="../h-ui/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="../h-ui/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="../h-ui/static/h-ui.admin/css/style.css" />
	<script type="text/javascript" src="../h-ui/lib/jquery/1.9.1/jquery.min.js"></script> 
	<script type="text/javascript" src="../h-ui/lib/layer/2.4/layer.js"></script>
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript">
	    添加和修改试题的js函数
	    //选择正确答案时，需要把答案赋给隐藏文本
	    function checkOption() {
	        var answer = "";
	        var ops = document.getElementsByName("op");
	        for (var i = 0; i < ops.length; i++) {
	            if (ops[i].checked) {
	                answer += ops[i].value;
	            }
	        }
	        document.getElementById("tqAnswer").value = answer;
	    }
	    分配试题的js函数
	    /*全选/反选*/
	    function checkAll(value) {
	        var score = 0;  //勾选的题目的总成绩
	        var count = 0;  //勾选的题目的总数目
	        var ids = "";   //勾选的题目的id集合
	        //得到所有的复选框
	        var inputs = document.getElementsByName("tqId");
	        //循环每个复选框
	        for (var i = 0; i < inputs.length; i++) {
	            //设置复选框是否选中
	            inputs[i].checked = value;
	            //如果选中
	            if (value == true) {
	                //得到复选框值中的试题id
	                ids += inputs[i].value.split(',')[0] + ",";
	                //得到复选框值中的试题分数
	                score += parseInt(inputs[i].value.split(',')[1]);
	                count++;
	            }
	        }
	        //截取掉id集合中的最后一个逗号
	        if (ids.length > 0) {
	            ids = ids.substring(0, ids.length - 1);
	        }
	        document.getElementById("ids").value = ids;             //把选中的试题的id集合赋给隐藏控件
	        document.getElementById("lbTpScore").innerText = score; //显示勾选的试题的总成绩
	        document.getElementById("lbTpCount").innerText = count; //显示勾选的试题的总数目

	    }
	    /*选择*/
	    function check() {
	        var score = 0;  //勾选的题目的总成绩
	        var count = 0;  //勾选的题目的总数目
	        var ids = "";   //勾选的题目的id集合
	        //得到所有的复选框
	        var inputs = document.getElementsByName("tqId");
	        //循环每个复选框
	        for (var i = 0; i < inputs.length; i++) {
	            //如果选中
	            if (inputs[i].checked == true) {
	                //得到复选框值中的试题id
	                ids += inputs[i].value.split(',')[0] + ",";
	                //得到复选框值中的试题分数
	                score += parseInt(inputs[i].value.split(',')[1]);
	                count++;
	            }
	        }
	        //截取掉id集合中的最后一个逗号
	        if (ids.length > 0) {
	            ids = ids.substring(0, ids.length - 1);
	        }
	        document.getElementById("ids").value = ids;             //把选中的试题的id集合赋给隐藏控件
	        document.getElementById("lbTpScore").innerText = score; //显示勾选的试题的总成绩
	        document.getElementById("lbTpCount").innerText = count; //显示勾选的试题的总数目
	    }

	</script>
</head>
<body>
    <nav class="breadcrumb">
		    <i class="Hui-iconfont">&#xe67f;</i> 
		    首页 <span class="c-gray en">&gt;</span> 
		    试题信息 <span class="c-gray en">&gt;</span> 
		    试卷管理 <span class="c-gray en">&gt;</span>
            试题分配
	 </nav>
    <form id="form1" runat="server" class="Huiform">
    <div>
	    <div class="page-container">
		    <div class="mt-20">
			    <table class="table table-border table-bordered table-bg table-hover table-sort" style="margin-bottom:20px">
                    <thead>
					            <tr class="text-c">
						            <th width="5%"><input type="checkbox" onclick="checkAll(this.checked)" /></th>
						            <th width="15%">课程</th>
						            <th width="60%">题目</th>
						            <th width="5%">类型</th>
						            <th width="5%">分值</th>
						            <th width="10%">操作</th>
					            </tr>
				     </thead>
                    <asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>
                                <tr class="text-c">
						            <td>
                                        <input type="checkbox" name="tqId" value='<%# Eval("tqId") %>,<%# Eval("tqScore") %>'  onclick="check()" />
						            </td>
						            <td><%# Eval("TkcId.tkcName") %></td>
						            <td name="tqName"><%# Eval("tqName") %></td>
                                    <td><%# Eval("tqtype") %></td>
						            <td><%# Eval("tqScore") %></td>
						            <td class="td-manage">
                                        <a style="text-decoration:none" class="ml-5" onclick="location.href='TQuestion_Info.aspx?id=<%# Eval("tqId") %>'" href="javascript:;" title="查看">
								            <i class="Hui-iconfont">&#xe665;</i>
							            </a>
						            </td>
					            </tr>
                            </ItemTemplate>
                    </asp:Repeater>
			    </table>
                </div>
	    </div>
        <div  style="position:fixed;bottom:5px;background-color:gainsboro;width:100%;text-align:right;">
                    <input type="hidden" id="ids" runat="server" value=""/>
                    试卷名:<font color="red"><label runat="server" id="lbTpName" >T001-内测</label></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    总成绩:<font color="red"><b><label runat="server" id="lbTpScore">0</label></b></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    总数目:<font color="red"><b><label runat="server" id="lbTpCount" >0</label></b></font>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button" class="btn btn-primary radius" style="background-color:dimgrey" value="  返  回  " onclick="history.go(-1);" />&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary radius" Text="  保  存  " OnClick="btnSave_Click" />&nbsp;&nbsp;&nbsp;&nbsp;
		 </div>
    </div>
    </form>
    <script>
        //防止试题名过长
        var tds = document.getElementsByName("tqName");
        for (var i = 0; i < tds.length; i++) {
            if (tds[i].innerText.length >= 50) {
                tds[i].innerText = tds[i].innerText.substring(0, 50);
            }
        }
    </script>
</body>
</html>
